﻿<phone:PhoneApplicationPage 
    x:Class="ChinaUnicom.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:controls="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
    xmlns:local="clr-namespace:ChinaUnicom.Controls"
    xmlns:src="clr-namespace:ChinaUnicom.Converters"
    mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="728" 
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Portrait"  Orientation="Portrait"
    shell:SystemTray.IsVisible="False"
    toolkit:TiltEffect.IsTiltEnabled="True">

    <!--Transitions-->
    <toolkit:TransitionService.NavigationInTransition>
        <toolkit:NavigationInTransition>
            <toolkit:NavigationInTransition.Backward>
                <toolkit:TurnstileTransition Mode="BackwardIn"/>
            </toolkit:NavigationInTransition.Backward>
            <toolkit:NavigationInTransition.Forward>
                <toolkit:TurnstileTransition Mode="ForwardIn"/>
            </toolkit:NavigationInTransition.Forward>
        </toolkit:NavigationInTransition>
    </toolkit:TransitionService.NavigationInTransition>
    <toolkit:TransitionService.NavigationOutTransition>
        <toolkit:NavigationOutTransition>
            <toolkit:NavigationOutTransition.Backward>
                <toolkit:TurnstileTransition Mode="BackwardOut"/>
            </toolkit:NavigationOutTransition.Backward>
            <toolkit:NavigationOutTransition.Forward>
                <toolkit:TurnstileTransition Mode="ForwardOut"/>
            </toolkit:NavigationOutTransition.Forward>
        </toolkit:NavigationOutTransition>
    </toolkit:TransitionService.NavigationOutTransition>

    <!--LayoutRoot is the root grid where all page content is placed-->
    <Grid x:Name="LayoutRoot" Background="Transparent">

        <Grid.Resources>
            <DataTemplate x:Key="basicTextTemplate">
                <TextBlock FontSize="28">
                    <Run Text="{Binding Name}"/><Run Text=" : "/><Run Text="{Binding Value}"/>
                </TextBlock>
            </DataTemplate>
            <Style TargetType="TextBlock" x:Key="panoramaItemHeader">
                <Setter Property="Foreground" Value="{StaticResource PhoneAccentBrush}"/>
                <Setter Property="FontSize" Value="62"/>
            </Style>
            <src:DateConverter x:Key="dateConverter"/>
        </Grid.Resources>

        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
        <Border Grid.Row="0" Background="#c40b0b">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="40"/>
                </Grid.RowDefinitions>
                <Image Grid.Row="0" Source="/Themes/Images/logo.png" Height="100" HorizontalAlignment="Left"/>
                <Grid x:Name="clientLabel" Grid.Row="1" Visibility="Collapsed">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="45"/>
                        <ColumnDefinition Width="100"/>
                        <ColumnDefinition Width="35"/>
                        <ColumnDefinition Width="*"/>
                    </Grid.ColumnDefinitions>
                    <Image Grid.Column="0" Source="/Themes/Images/user.png" Height="35" HorizontalAlignment="Right"/>
                    <TextBlock x:Name="clientLabelName" Grid.Column="1" Text="" HorizontalAlignment="Left" VerticalAlignment="Center"/>
                    <Image Grid.Column="2" Source="/Themes/Images/phone.png" Height="35" HorizontalAlignment="Right"/>
                    <TextBlock x:Name="clientLabelMobile" Grid.Column="3" Text="" HorizontalAlignment="Left" VerticalAlignment="Center"/>
                </Grid>
            </Grid>
        </Border>
        <controls:Pivot x:Name="mainContainer" Grid.Row="1" SelectionChanged="OnMainContainerSelectionChanged">
            <controls:PivotItem>
                <controls:PivotItem.Header>
                    <TextBlock Text="套餐余量" FontSize="36"/>
                </controls:PivotItem.Header>
                <ScrollViewer>
                    <StackPanel>
                        <ItemsControl Margin="10 0" x:Name="packageBaseinfo" Visibility="Collapsed">
                            <TextBlock Foreground="{StaticResource PhoneSubtleBrush}">
                                <Run Text="套餐名称"/><Run Text=" : "/><Run Text="{Binding Name}"/>
                            </TextBlock>
                            <TextBlock Foreground="{StaticResource PhoneSubtleBrush}">
                                <Run Text="查询日期"/><Run Text=" : "/><Run Text="{Binding Occurred, Converter={StaticResource dateConverter}}"/>
                            </TextBlock>
                            <TextBlock Foreground="{StaticResource PhoneSubtleBrush}">
                                <Run Text="起止日期"/><Run Text=" : "/><Run Text="{Binding Started, Converter={StaticResource dateConverter}}"/><Run Text=" ~ "/><Run Text="{Binding Ended, Converter={StaticResource dateConverter}}"/>
                            </TextBlock>
                        </ItemsControl>
                        <local:PackageList Margin="10 0" x:Name="packageList"/>
                    </StackPanel>
                </ScrollViewer>
            </controls:PivotItem>

            <controls:PivotItem>
                <controls:PivotItem.Header>
                    <TextBlock Text="当月话费" FontSize="36"/>
                </controls:PivotItem.Header>
                <ScrollViewer>
                    <StackPanel>
                        <ItemsControl Margin="10 0" x:Name="feeBaseinfo" Visibility="Collapsed">
                            <TextBlock Foreground="{StaticResource PhoneSubtleBrush}">
                                <Run Text="查询日期"/><Run Text=" : "/><Run Text="{Binding Occurred, Converter={StaticResource dateConverter}}"/>
                            </TextBlock>
                            <TextBlock Foreground="{StaticResource PhoneSubtleBrush}">
                                <Run Text="起止日期"/><Run Text=" : "/><Run Text="{Binding Started, Converter={StaticResource dateConverter}}"/><Run Text=" ~ "/><Run Text="{Binding Ended, Converter={StaticResource dateConverter}}"/>
                            </TextBlock>
                        </ItemsControl>
                        <ItemsControl x:Name="feeDetailsinfo" Margin="10,10,10,0" ItemTemplate="{StaticResource basicTextTemplate}" />
                    </StackPanel>
                </ScrollViewer>
            </controls:PivotItem>

            <controls:PivotItem>
                <controls:PivotItem.Header>
                    <TextBlock Text="我的信息" FontSize="36"/>
                </controls:PivotItem.Header>
                <ScrollViewer>
                    <ItemsControl x:Name="clientInfo" Margin="10,10,10,0" ItemTemplate="{StaticResource basicTextTemplate}" />
                </ScrollViewer>
            </controls:PivotItem>
        </controls:Pivot>

        <ProgressBar Grid.Row="1" x:Name="progressBar" IsEnabled="False" IsIndeterminate="False" Visibility="Collapsed" VerticalAlignment="Top" />
    </Grid>
    <!--Sample code showing usage of ApplicationBar-->
    <phone:PhoneApplicationPage.ApplicationBar>
        <shell:ApplicationBar IsVisible="True" IsMenuEnabled="True">
            <shell:ApplicationBarIconButton x:Name="refreshIconButton" IconUri="/Themes/Images/refresh.png" IsEnabled="False" Text="刷新" Click="OnRefreshClick"/>
            <shell:ApplicationBarIconButton x:Name="settingsIconButton" IconUri="/Themes/Images/settings.png" Text="设置" Click="OnSettingsPageClick"/>
        </shell:ApplicationBar>
    </phone:PhoneApplicationPage.ApplicationBar>
</phone:PhoneApplicationPage>